# file:: template_with_logic.rb
# author::  Ralph M. Churchill
# version::
# date::
#
# This source code copyright (C) 2006 by Ralph M. Churchill
# All rights reserved.
#
# Released under the terms of the GNU General Public License
# See LICENSE file for additional information.

module TemplateHasLogic
    properties :default_logic_modules

    def apply_logic_to_instance(instance)
        self.default_logic_modules ||= []
        self.default_logic_modules.each do |logic_name|
            logic_class = Object.const_get(logic_name)
            begin
                logic = logic_class.new(instance)
                instance.add_logic(logic)
            rescue => e
                $stderr.puts("Could not add #{logic_name} to #{instance}: #{e}")
            end
        end
    end
end
